import React from 'react';
import { connect } from "react-redux";
import { bindActionCreators } from "redux";
import * as Action from "./actions";
import { HashRouter as Router, Route, Link } from 'react-router-dom'

class Success extends React.Component {
    constructor(props) {
        super(props);
        this.state=({
            parm:JSON.parse(sessionStorage.getItem('userOpenid'))
        })
        
    }

    render() {
        document.title="下单成功";
        return <Router>
            <div style={{height:"100%"}}>
                <div className="success">
                    <div className="subanner">
                        <span className="suclogo"><img src="images/123_r2_c2.jpg" /></span>
                        <div className="suinfo">
                            <h2>下单成功！请您稍微等待</h2>
                            <p className="orderId"><span>订单号码:</span><a>{this.props.condition.orderId}</a></p>
                        </div>
                    </div>
                </div>
                <div className="suconfirm">
                    <div>
                        <Link to="/order" onClick={()=>{this.props.actions.orderInfo(`orderId=${this.props.condition.orderId}&userOpenId=${this.state.parm.userOpenid}`)}}>返回订单详情</Link>
                    </div>
                </div>
            </div>
        </Router>
    }
}
export default connect(
    ({ foodReducer }) => {
        return {
            condition: foodReducer.condition
        }
    },
    (dispatch) => {
        return {
            actions: bindActionCreators(Action, dispatch)
        }
    }
)(Success)